﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
using System.Text;
using LSBLL;
using LSEntity;
using LSInterFace;
using MathematicsEntity;
using MathematicsInterface;

namespace MathematicsBLL
{
    public class KSBControllerFormat<T, TResult> : IControllerFormat<TResult> where T : IKSBControllerFormat<TResult>, new()
    {
        public string Area
        {
            get { return KSBWebConfig.Area; }
        }

        public void Init(WebPageConfig webPageConfig, MemberEntity member)
        {
            var cache = new MathematicsCache<CourseCollection>(new MemoryEntity
                                                                   {
                                                                       GetData = () => KSBBLL.CourseGetList(webPageConfig),
                                                                       MemoryKey = KSBWebConfig.CourseCacheKey,
                                                                       FilePaths = new List<string>
                                                                                     {
                                                                                        KSBBLL.CourseXMLPath(webPageConfig)
                                                                                     },
                                                                       TimeSpan = new TimeSpan(0, 10, 0),
                                                                   });
            cache.MemoryModel();
        }

        public TResult GetModel(WebPageConfig webPageConfig, MemberEntity member)
        {
            return new T().GetCommonModel();
        }
    }

    public class KSBStudentControllerFormatBLL : IKSBControllerFormat<KSBCommonNone>
    {
        public KSBCommonNone GetCommonModel()
        {
            return new KSBCommonNone();
        }
    }

    public class KSBTeacherControllerFormatBLL : IKSBControllerFormat<KSBCommonNone>
    {
        public KSBCommonNone GetCommonModel()
        {
            return new KSBCommonNone();
        }
    }

    public class KSBControllerFormatBLL : IKSBControllerFormat<KSBCommonNone>
    {
        public KSBCommonNone GetCommonModel()
        {
            return new KSBCommonNone();
        }
    }
}
